#include "AllToAllBench.h"



void AllToAllBench::executeFFT() { executeFFT(false); }

void AllToAllBench::executeFFT(bool onlyComm) {



	//transpose
	//MPI_Alltoall(localData,2,MPI_DOUBLE,localBuff,2,MPI_DOUBLE,MPI_COMM_WORLD);

	for (int mSize=1; mSize <= MAXN; mSize*=2) {

		int trial;
		double startTime;
		double endTime;

		MPI_Barrier(MPI_COMM_WORLD);
		
		startTime = MPI_Wtime();
		for (trial=0; trial < 10; trial++) {
			MPI_Alltoall(sendBuff,mSize,MPI_DOUBLE,recBuff,mSize,MPI_DOUBLE,MPI_COMM_WORLD);
		
			//swap send and rec pointers
			double *tmp = sendBuff;
			sendBuff = recBuff;
			recBuff = tmp;
		}
		
		endTime = MPI_Wtime();
		if (rank == 0) {
			printf("T;%d;%d;%lf\n",numNodes,mSize,(endTime-startTime)/trial);
		}		

	}
	
}

